{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "import Batch as bh\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "pathdataSet = 'D:/homework/pre/dataSetfilterFeature.csv'\n",
    "pathSaveModel = 'D:/homework/pre/net/'\n",
    "pathSaveModelMeta = 'D:/homework/pre/net/mynet.meta'\n",
    "\n",
    "pathTestLogs = 'D:/homework/pre/logs/originalDataTest'\n",
    "dataSetTest = pd.read_csv(pathdataSet)\n",
    "\n",
    "\n",
    "m,n = dataSetTest.shape\n",
    "\n",
    "#这里batch_size的大小要和训练集的batch_size的相同，即模型输入端的数据格式要相同\n",
    "batch_size=5000 \n",
    "test_iters = 40\n",
    "n_inputs= n-1                \n",
    "n_steps = 1\n",
    "\n",
    "\n",
    "dataSetTest = bh.Dataset(dataSetTest)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:Restoring parameters from D:/homework/pre/net/mynet\n",
      "0.9916\n",
      "0.9926\n",
      "0.9922\n",
      "0.9912\n",
      "0.992\n",
      "0.9918\n",
      "0.9938\n",
      "0.9908\n",
      "0.9924\n",
      "0.9914\n",
      "0.991\n",
      "0.9946\n",
      "0.9928\n",
      "0.9912\n",
      "0.9906\n",
      "0.9912\n",
      "0.9922\n",
      "0.9938\n",
      "0.9918\n",
      "0.9924\n",
      "0.9938\n",
      "0.9914\n",
      "0.993\n",
      "0.9922\n",
      "0.9914\n",
      "0.994\n",
      "0.9916\n",
      "0.9912\n",
      "0.9918\n",
      "0.9908\n",
      "0.9904\n",
      "0.9898\n",
      "0.9918\n",
      "0.9902\n",
      "0.9922\n",
      "0.9912\n",
      "0.9926\n",
      "0.9906\n",
      "0.9918\n",
      "0.9912\n"
     ]
    }
   ],
   "source": [
    "with tf.Session() as sess:\n",
    "    my_saver = tf.train.import_meta_graph(pathSaveModelMeta)\n",
    "    my_saver.restore(sess,tf.train.latest_checkpoint(pathSaveModel))\n",
    "    graph = tf.get_default_graph()\n",
    "    writer_test=tf.summary.FileWriter(pathTestLogs,sess.graph)\n",
    "    x = graph.get_tensor_by_name(\"Input/x:0\")              \n",
    "    y = graph.get_tensor_by_name(\"Input/y:0\")\n",
    "    Accuracy = graph.get_tensor_by_name(\"Accuracy/Accuracy:0\")\n",
    "    tf.summary.scalar('Accuracy',Accuracy)\n",
    " \n",
    "    merged=tf.summary.merge_all() \n",
    "    \n",
    "    step=0\n",
    "    while step<test_iters:\n",
    "        dataSet = dataSetTest.next_batch(batch_size)\n",
    "        batch_train_xs = np.array(dataSet.drop(['label'],axis = 1))\n",
    "        batch_train_xs = batch_train_xs.reshape([-1,n_steps,n_inputs])\n",
    "        batch_train_ys = np.array(dataSet['label'])\n",
    "        print(sess.run(Accuracy,feed_dict={x:batch_train_xs,y:batch_train_ys }))\n",
    "        summary=sess.run(merged,feed_dict={x:batch_train_xs,y:batch_train_ys})\n",
    "        writer_test.add_summary(summary,step)\n",
    "        step+=1\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
